﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Data;
using SmartEP.Model;
using SmartEP.DTO;

namespace SmartEP.DataService
{
    public class ClaimInfoService
    {
        private ClaimModel claimModel;

        public ClaimInfoService()
        {
            claimModel = new ClaimModel();
        }

        public IList<Claim> GetInsuranceClaims()
        {
            DataView view = claimModel.GetInsuranceClaimsByProvider(0).Tables[0].DefaultView;
            IList<Claim> claims = new List<Claim>();

            foreach (DataRowView row in view)
            {
                Claim claim = new Claim(Convert.ToInt32(row[ClaimModel.ID_FIELD]));

                claim.Member = new Patient();
                claim.Member.FirstName = Convert.ToString(BaseModel.GetFieldValue(row, PatientModel.FIRST_NAME_FIELD));
                claim.Member.MiddleName = Convert.ToString(BaseModel.GetFieldValue(row, PatientModel.MIDDLE_NAME_FIELD));
                claim.Member.LastName = Convert.ToString(BaseModel.GetFieldValue(row, PatientModel.LAST_NAME_FIELD));
                claim.Member.Birthday = Convert.ToDateTime(BaseModel.GetFieldValue(row, PatientModel.BIRTHDAY_FIELD));

                claim.CPTs = Convert.ToString(BaseModel.GetFieldValue(row, ClaimModel.CPT_ALL_FIELD));
                claim.Plan = Convert.ToString(BaseModel.GetFieldValue(row, ClaimModel.PLAN_FIELD));
                claim.InsurancePlan = Convert.ToString(BaseModel.GetFieldValue(row, ClaimModel.INSURANCE_PLAN_FIELD));
                claim.Amount = Convert.ToString(BaseModel.GetFieldValue(row, ClaimModel.AMOUNT_FIELD));
                claim.CreatedDate = Convert.ToDateTime(BaseModel.GetFieldValue(row, ClaimModel.CREATED_DATE_FIELD));
                claim.Status = Convert.ToString(BaseModel.GetFieldValue(row, ClaimModel.STATUS_FIELD));

                claims.Add(claim);
            }

            return claims;
        }
    }
}
